<!doctype html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>辰乡乐</title>
    <link rel="stylesheet" type="text/css" href="./css/api.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <style> </style>
</head>
<!-- 	<preference name="android_abi" value="arm64-v8a"/> -->

<body>

</body>

</html>
<script type="text/javascript" src="script/api.js"></script>
<script type="text/javascript">
    apiready = function () {
        console.log('重启应用');
        initPage()
        fnInitEvent();
    }

    function fnInitEvent() {
        var exitFlag = false;
        api.addEventListener({
            name: 'keyback'
        }, function (ret, err) {
            if (!exitFlag) {
                api.toast({
                    msg: '再次返回退出应用',
                    duration: 2000,
                    location: 'bottom'
                });
                exitFlag = true;
            } else {
                api.closeWidget({
                    silent: true
                });
            }
            setTimeout(function () {
                exitFlag = false;
            }, 2000);
        });
    };


    function initPage() {
        api.setStatusBarStyle({
            style: 'dark'
        });

        var tabs = [{
            "name": "main",
            "url": "html/main.html",
            "title": "首页"
        }
        ];
        var icos = [{
            "text": "首页",
            "iconPath": "images/icon/icon_nor_home.png",
            "selectedIconPath": "images/icon/icon_hover_home.png"
        }];
        var userObj = $api.getStorage('userinfo');
        if (userObj && userObj.token) {
            tabs.push({
                "name": "task",
                "url": "html/task.html",
                "title": "任务"
            });

            tabs.push({
                "name": "finder",
                "url": "html/finder.html",
                "title": "发现"
            });

            icos.push({
                "text": "任务",
                "iconPath": "images/icon/icon_nor_landscape.png",
                "selectedIconPath": "images/icon/icon_hover_landscape.png"
            });
            icos.push({
                "text": "发现1",
                "iconPath": "images/icon/icon_nor_landscape.png",
                "selectedIconPath": "images/icon/icon_hover_landscape.png"
            });
            

        }


        tabs.push({
            "name": "scenic",
            "url": "html/scenic.html",
            "title": "景区"
        });

        // tabs.push( {
        //     "name": "video",
        //     "url": "html/video.html",
        //     "title": "视频" 
        // });
        tabs.push( {
            "name": "point",
            "url": "html/point.html",
            "title": "积分" 
        });
        tabs.push({
            "name": "user",
            "url": "html/user.html",
            "title": "我的"
        });

        icos.push({
            "text": "景区",
            "iconPath": "images/icon/icon_nor_landscape.png",
            "selectedIconPath": "images/icon/icon_hover_landscape.png"
        });

        // icos.push({
        //     "text": "视频",
        //     "iconPath": "images/icon/icon_nor_vedio.png",
        //     "selectedIconPath": "images/icon/icon_hover_vedio.png"
        // });
        icos.push( {
            "text": "积分",
            "iconPath": "images/icon/icon_nor_points.png",
            "selectedIconPath": "images/icon/icon_hover_jifen.png"
        });

        icos.push({
            "text": "我的",
            "iconPath": "images/icon/icon_nor_mine.png",
            "selectedIconPath": "images/icon/icon_hover_mine.png"
        });
        api.openTabLayout({
            name: 'homepage',
            url: 'index.html',
            hideTabBar: false,
            slidBackEnabled: false,
            "tabBar": {
                "scrollEnabled": false,
                "background": "#fff",
                "shadow": "#f1f1f1",
                "color": "#aaa",
                "selectedColor": "#7A33D8",
                "preload": 0,
                "frames": tabs,
                "list": icos
            }
        });
    }
</script>